package com.baizhi.controller;

import com.baizhi.Brand;
import com.baizhi.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/brand")
public class BrandController {
    @Autowired
    private BrandService bs;
    @RequestMapping("/show")
    public String  showBrand(Model model){
        List<Brand> brands = bs.selectBrand();
        model.addAttribute("s",brands);
        System.out.println(brands);
        return "forward:/brandList.jsp";
    }
    @RequestMapping("find")
    public String showBrands(Model model){
        List<Brand> brands = bs.selectProduct();
        model.addAttribute("c",brands);
        return "forward:/addPhone.jsp";
    }
    public void deletre(){

    }
    @RequestMapping("finds")
    public String showBrands1(Model model){
        List<Brand> brands = bs.selectProduct();
        model.addAttribute("c",brands);
        return "forward:/updatePhone.jsp";
    }
    @RequestMapping("insert")
    public String inset(Brand brand){
        bs.insertBrand(brand);
        return "forward:/brand/show.do";
    }
    @RequestMapping("delete")
    public String delete(int id){
        bs.delete(id);
        return "forward:/brand/show.do";
    }
}